*** set working directory
cd "/Users/Jeff/Dropbox/Research/Ongoing Research/ICM/JumpStart/Jeff/Replication Files"

use "jumpstart_final.dta", clear

*******************************************
********* Regression analysis *************
*******************************************
set matsize 5000

********** Primary outcomes ***********
** OLS and Instrumental variable **
* Note - omitted group: no kindergarten


* Outcome: Best in third grade
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A2 
reg best_in_third jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder 

* Appendix Table A2
reg best_in_third jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Table 2
reg best_in_third jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table2.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder 

* Table 2
ivreghdfe best_in_third too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table2.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Outcome: Best in Elementary School
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A2
reg best_in_elem jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Appendix Table A2
reg best_in_elem jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Table 2
reg best_in_elem jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table2.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Table 2
ivreghdfe best_in_elem too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table2.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Outcome: Percentile rank in third grade
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A2
reg Section1_full jumpstart gov_kinder too_young_third `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Appendix Table A2
reg Section1_full jumpstart gov_kinder too_young_third `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Table 2
reg Section1_full jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table2.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Table 2
reghdfe Section1_full too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table2.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

** Boostrap standard errors (because 15% of the sample is missing and we predicted values)
* child and mother controls
local boots = 1000
clear
set obs `boots'
gen js_means = .
gen gov_means = .
quietly{
	forvalues i = 1(1) `boots' {
		if floor((`i'-1)/100) == (`i'-1)/100 {
			noisily display "Working on `i' out of `boots'" 
			}
			
		preserve
		do js_cleanDO
		set matsize 5000
		
		local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
		local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

		
		bsample, strata(village_id) 

		reg Section1_full jumpstart gov_kinder `child_controls' `mom_controls', cluster(village_id)
				
		local mean_js = _b[jumpstart]
		local mean_gov = _b[gov_kinder]
		
		restore
		
		replace js_means = `mean_js' in `i'
		replace gov_means = `mean_gov' in `i'
	
}
}
save "bootstrap_topsect_1_binary.dta", replace
* Village fixed effects 
local boots = 1000
clear
set obs `boots'
gen js_means = .
gen gov_means = .
quietly{
	forvalues i = 1(1) `boots' {
		if floor((`i'-1)/100) == (`i'-1)/100 {
			noisily display "Working on `i' out of `boots'" 
			}
			
		preserve
		do js_cleanDO
		set matsize 5000
		
		local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
		local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"


		bsample, strata(village_id)
		
		reg Section1_full jumpstart gov_kinder `child_controls' `mom_controls' i.village_id, cluster(village_id)
		
		local mean_js = _b[jumpstart]
		local mean_gov = _b[gov_kinder]
		
		restore
		
		replace js_means = `mean_js' in `i'
		replace gov_means = `mean_gov' in `i'
	
}
}
save "boostrap_topsect_2_binary.dta", replace
* Mother/household fixed effects
local boots = 1000
clear
set obs `boots'
gen js_means = .
gen gov_means = .
quietly{
	forvalues i = 1(1) `boots' {
		if floor((`i'-1)/100) == (`i'-1)/100 {
			noisily display "Working on `i' out of `boots'" 
			}
			
		preserve
		do js_cleanDO
		set matsize 5000
		
		local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
		
		bsample, strata(village_id)

		reg Section1_full jumpstart gov_kinder `child_controls' i.hhid_numeric, cluster(village_id)
				
		local mean_js = _b[jumpstart]
		local mean_gov = _b[gov_kinder]
		
		restore
		
		replace js_means = `mean_js' in `i'
		replace gov_means = `mean_gov' in `i'
	
}
}
save "boostrap_topsect_3_binary.dta", replace
* instrumental variables
local boots = 1000
clear
set obs `boots'
gen js_means = .
gen gov_means = .
quietly{
	forvalues i = 1(1) `boots' {
		if floor((`i'-1)/100) == (`i'-1)/100 {
			noisily display "Working on `i' out of `boots'" 
			}
			
		preserve
		do js_cleanDO
		set matsize 5000
		
		local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
		* Predict missing section1 values
		
		bsample, strata(village_id)
		
		ivregress 2sls Section1_full `child_controls' i.hhid_numeric ///
		(jumpstart gov_kinder = js1 js2 js3 js4 js5 js6 js7 ///
		js8 js9 js10 js11 js12 js13 js14 js15 js16 js17 js18 js19 js20 js21 js22 js23 ///
		js24 js25 js26 js27 js28 js29 js30 gov1 gov2 gov3 gov4 gov5 gov6 gov7 gov8 gov9 ///
		gov10 gov11 gov12 gov13 gov14 gov15 gov16 gov17 gov18 gov19 gov20 gov21 gov22 gov23 ///
		gov24 gov25 gov26 gov27 gov28 gov29 gov30), vce(cluster village_id)
		
		local mean_js = _b[jumpstart]
		local mean_gov = _b[gov_kinder]
		
		restore
		
		replace js_means = `mean_js' in `i'
		replace gov_means = `mean_gov' in `i'
	
}
}
save "boostrap_topsect_4_binary.dta", replace

* Outcome: currently enrolled in school
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A2
reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' `mom_controls', cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Appendix Table A2
reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' `mom_controls' i.village_id, cluster(village_id)
outreg2 using TableA1.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Table 2
reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using Table2.tex, keep(jumpstart gov_kinder) 
test jumpstart = gov_kinder 

* Table 2
reghdfe child_enroll too_young_enroll too_old_enroll `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using Table2.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

*** Get first stage estimates

local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

reghdfe jumpstart too_young_third `child_controls' age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10, ///
absorb(hhid_numeric) cluster(village_id)
outreg2 using IV_first.tex, keep(age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10) replace

reghdfe gov_kinder too_young_third `child_controls' age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10, ///
absorb(hhid_numeric) cluster(village_id)
outreg2 using IV_first.tex, keep(age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10)

reghdfe jumpstart too_young_enroll too_old_enroll `child_controls' age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10, ///
absorb(hhid_numeric) cluster(village_id)
outreg2 using IV_first.tex, keep(age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10)

reghdfe gov_kinder too_young_enroll too_old_enroll `child_controls' age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10, ///
absorb(hhid_numeric) cluster(village_id)
outreg2 using IV_first.tex, keep(age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10)

******** Robustness - drop kids who are "too young" or "too old" ********

* Outcome: Best in third grade
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A18
reghdfe best_in_third jumpstart gov_kinder `child_controls' if child_age>8, absorb(hhid_numeric) cluster(village_id)
outreg2 using TableA18.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder 

* Appendix Table A18
ivreghdfe best_in_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10) if child_age>8, ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA18.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Outcome: Best in Elementary School
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A18
reghdfe best_in_elem jumpstart gov_kinder `child_controls' if child_age>5, absorb(hhid_numeric) cluster(village_id)
outreg2 using TableA18.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Appendix Table A18
ivreghdfe best_in_elem `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10) if child_age>5, ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA18.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Outcome: Percentile rank in third grade
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A18
reghdfe Section1_full jumpstart gov_kinder `child_controls' if child_age>8, absorb(hhid_numeric) cluster(village_id)
outreg2 using TableA18.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Appendix Table A18
ivreghdfe Section1_full `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10) if child_age>8, ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA18.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Outcome: currently enrolled in school
local child_controls = "child_sex child_age first_born second_born third_born fourth_born"
local mom_controls = "ihs_hh_income hh_income_missing hh_num hh_num_missing mom_age mom_highschool mom_college mother_married stayathome mom_vhlgrad"

* Appendix Table A18
reghdfe child_enroll jumpstart gov_kinder `child_controls' if child_age>3 & child_age<25, absorb(hhid_numeric) cluster(village_id)
outreg2 using TableA18.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Appendix Table A18
ivreghdfe child_enroll `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10) if child_age>3 & child_age<25, ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA18.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

***************** Heterogeneity by sex **********************************
drop num_hh drop_flag

* Outcome: Best in third grade

preserve
keep if child_sex==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A2 (female)
reg best_in_third jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder 

* Table A2 (female)
reghdfe best_in_third too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

restore
preserve
keep if child_sex==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A3 (male)
reg best_in_third jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder) replace
test jumpstart = gov_kinder 

* Table A3 (male)
reghdfe best_in_third too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

restore

* Outcome: Best in elementary 

preserve
keep if child_sex==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A3 (female)
reg best_in_elem jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Table A3 (female)
reghdfe best_in_elem too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

restore
preserve
keep if child_sex==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A3 (male)
reg best_in_elem jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Table A3 (male)
reghdfe best_in_elem too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

restore

* Outcome: Top third grade section 
preserve
keep if child_sex==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A3 (female)
reg Section1_full jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Table A3 (female)
reghdfe Section1_full too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

restore
preserve
keep if child_sex==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A3 (male)
reg Section1_full jumpstart gov_kinder too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Table A3 (male)
reghdfe Section1_full too_young_third `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

restore

* Outcome: Currently enrolled
preserve
keep if child_sex==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A3 (female)
reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Table A3 (female)
reghdfe child_enroll too_young_enroll too_old_enroll `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2a.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder

restore
preserve
keep if child_sex==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1 

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A3 (male)
reg child_enroll jumpstart gov_kinder too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

* Table A3 (male)
reghdfe child_enroll too_young_enroll too_old_enroll `child_controls' ///
(jumpstart gov_kinder = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10 age_gk_intro_ls0 age_gk_intro_1 age_gk_intro_2 age_gk_intro_3 age_gk_intro_4 ///
age_gk_intro_5 age_gk_intro_6 age_gk_intro_7 age_gk_intro_8 age_gk_intro_9 age_gk_intro_10), ///
absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA2b.tex, keep(jumpstart gov_kinder)
test jumpstart = gov_kinder 

restore

************ Heterogeneity by age (did program get better over time?) **********
drop num_hh drop_flag
gen less_than_11 = (child_age<11)
xtset hhid_numeric

* Outcome: Best in third grade

preserve
keep if less_than_11==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 11 or older)
reg best_in_third jumpstart too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3a.tex, keep(jumpstart) replace

* Table A4 (Age 11 or older)
reghdfe best_in_third too_young_third `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3a.tex, keep(jumpstart)

restore
preserve
keep if less_than_11==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 10 or less)
reg best_in_third jumpstart too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3b.tex, keep(jumpstart) replace

* Table A4 (Age 10 or less)
reghdfe best_in_third too_young_third `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3b.tex, keep(jumpstart)

restore

* Outcome: Best in elementary 

preserve
keep if less_than_11==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 11 or older)
reg best_in_elem jumpstart too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3a.tex, keep(jumpstart)

* Table A4 (Age 11 or older)
reghdfe best_in_elem too_young_third `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3a.tex, keep(jumpstart)

restore
preserve
keep if less_than_11==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 10 or less)
reg best_in_elem jumpstart too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3b.tex, keep(jumpstart)

* Table A4 (Age 10 or less)
reghdfe best_in_elem too_young_third `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3b.tex, keep(jumpstart)

restore

* Outcome: Placed in top section

preserve
keep if less_than_11==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 11 or older)
reg Section1_full jumpstart too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3a.tex, keep(jumpstart)

* Table A4 (Age 11 or older)
reghdfe Section1_full too_young_third `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3a.tex, keep(jumpstart)

restore
preserve
keep if less_than_11==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 10 or less)
reg Section1_full jumpstart too_young_third `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3b.tex, keep(jumpstart)

* Table A4 (Age 10 or less)
reghdfe Section1_full too_young_third `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3b.tex, keep(jumpstart)

restore

* Outcome: Current enrollment

preserve
keep if less_than_11==0
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 11 or older)
reg child_enroll jumpstart too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3a.tex, keep(jumpstart)

* Table A4 (Age 11 or older)
reghdfe child_enroll too_young_enroll too_old_enroll `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3a.tex, keep(jumpstart)

restore
preserve
keep if less_than_11==1
* drop households with only one kid
duplicates tag hhid_numeric, gen(num_hh)
gen drop_flag = 1 if num_hh==0
drop if drop_flag==1

local child_controls = "child_age first_born second_born third_born fourth_born"
* Table A4 (Age 10 or less)
reg child_enroll jumpstart too_young_enroll too_old_enroll `child_controls' i.hhid_numeric, vce(cluster village_id)
outreg2 using TableA3b.tex, keep(jumpstart)

* Table A4 (Age 10 or less)
reghdfe child_enroll too_young_enroll too_old_enroll `child_controls' ///
(jumpstart = age_js_intro_ls0 age_js_intro_1 age_js_intro_2 age_js_intro_3 ///
age_js_intro_4 age_js_intro_5 age_js_intro_6 age_js_intro_7 age_js_intro_8 age_js_intro_9 ///
age_js_intro_10), absorb(hhid_numeric) cluster(village_id) ffirst
outreg2 using TableA3b.tex, keep(jumpstart)

restore

